<div class="inside">
  <aside class="navigationPanel">
     
     <div class="tree pagesLinks">
        <ul>
           <ul>
              <?php if($this->session->userdata('level') == 1):?>
              <li> <a href="<?php echo $baseurl.'account.html'?>" class="active">Danh sách tài khoản</a> </li>
              <li> <a href="<?php echo $baseurl.'classify-device.html'?>">Phân loại nhóm khách hàng</a> </li>
              <?php endif;?>  
              <li> <a href="<?php echo $baseurl.'setting.html'?>">Thông tin tài khoản</a> </li>
              <li> <a href="<?php echo $baseurl.'setting-password.html'?>">Mật khẩu</a> </li>
           </ul>
        </ul>
     </div>
  </aside>
  <div class="contentPanel">
     <div class="pages" id="profile">
        <div class="profile-edit-form">
              <?php $att = array('id' => 'frm-profileEdit-editForm', 'class' => 'profileForm');echo form_open('', $att);?>
              <input type="hidden" value="<?php echo $id?>" name="id" />
              <div class="contentBox switcher" style="height: 100%;">
                 <h3>Sửa tài khoản</h3>
                 <?php if(validation_errors()):?>
                    <h4>
                        <p><?php echo validation_errors(); ?></p>
                    </h4>
                    <?php endif;?>
                 <div class="contentSwitcher hide" style="display: block;">
                    <div class="insideContentBox">
                       <label for="frm-fullname">Tài khoản (*):</label> 
                       <input type="text" name="username" disabled="disabled" value="<?php echo $data->username?>" class="ipt" autocomplete="off" id="frm-username" placeholder="Nhập tên tài khoản">
                       
                       <label for="frm-fullname">Mật khẩu:</label> 
                       <input type="password" name="password" value="" class="ipt" autocomplete="off" id="frm-password" placeholder="Nhập mật khẩu">
                       
                       <label for="frm-fullname">Xác nhận mật khẩu:</label> 
                       <input type="password" name="passwordVerify" value="" class="ipt" autocomplete="off" id="frm-password"  placeholder="Nhập lại mật khẩu">
                       
                       <label for="frm-fullname">Họ tên (*):</label> 
                       <input type="text" name="fullname" value="<?php echo $data->fullname?>" class="ipt" autocomplete="off" id="frm-fullname" placeholder="Nhập họ tên">
                       
                       <label for="frm-mobile">Số điện thoại (*):</label> 
                       <input type="text" name="mobile" value="<?php echo $data->mobile?>" class="ipt" autocomplete="off" id="frm-mobile" placeholder="Nhập số điện thoại">
                       
                       <label for="frm-email">Email (*):</label> 
                       <input type="text" name="email"  value="<?php echo $data->email?>" class="ipt" autocomplete="off" id="frm-email" placeholder="Nhập email">
                       
                       <label for="frm-address">Địa chỉ:</label> 
                       <input type="text" name="address"  value="<?php echo $data->address?>" class="ipt" autocomplete="off" id="frm-address" placeholder="Nhập địa chỉ">
                 
                       <label for="frm-address">Công ty:</label> 
                       <input type="text" name="company"  value="<?php echo $data->company?>" class="ipt" autocomplete="off" id="frm-address"  placeholder="Nhập công ty">
                       
                       <label for="frm-address">Loại tài khoản (*):</label> 
                       <div class="custom-line">
                           <span>
                               <?php echo $fview->selectType(array('Wicity System', 'Agency', 'End Users', 'Agency 1 Place'), $data->level, 'level', 1)?>
                           </span>
                       </div>
                       
                       <div id="list-agency" style="display: none;">
                            <label for="frm-address">Agency (*):</label> 
                           <div class="inputHolder c" id="content-list-agency">
                                <h4 style="color: red;font-weight: normal">Đang tải dữ liệu...</h4>
                                <input name="agency" value="0" type="hidden"/>
                           </div>
                       </div> 
					   <div id="list-place" style="display: none;">
                            <label for="frm-address">Agency 1 Place (*):</label> 
                           <div class="inputHolder c" id="content-list-place">
                                <h4 style="color: red;font-weight: normal">Đang tải dữ liệu...</h4>
                                <input name="place" value="0" type="hidden"/>
                           </div>
                       </div>                                                                                                                                                                   
                       <label for="frm-img">Ảnh đại diện:</label> 
                        <div class="uploadImage">
                            <img src="<?php echo $data->img ? $baseurl.$data->img : $baseurl.'public/assets/images/avatar.png' ;?>" id="display_image_" onError="this.src='<?php $baseurl;?>public/upload/default.jpg';"/>
                            <input class="image-input" type="file" name="img_uploads" id="image_upload" onchange="convertimage('image_upload', 'image_', 'display_image_');" value="" />
                            <label class="hidden-label" for="image_upload"></label>
                            <input type="hidden" name="image_" id="image_" value="" />
                            <input type="hidden" name="image_verify" id="image_verify" value="<?php echo $data->img?>" />
                            <input type="hidden" name="image_check" id="image_check" value="<?php echo $data->img?>" />
                        </div>
                       <!--div class="inputHolder c">
                          <input type="hidden" name="img_hidden" id="img_hd" value="" />
                          <input type="file" name="img" onchange="convertimage();" class="cfr" autocomplete="off" id="frm-img">
                          <div class="req"></div>
                          <div class="reqBar"></div>
                       </div-->
                       
                       <label for="frm-address">Trạng thái:</label>
                       <div class="custom-line">
                           <span>
                               <?php echo $fview->selectType(array('Tạm khóa', 'Kích hoạt'), $data->active, 'active', 0)?>
                           </span>
                       </div>
                       
                       <div class="lineButton">
                           <button type="submit" class="applyBtn btn btn-small btn-primary"><span>Lưu lại</span></button>
                           <button type="button" onclick="window.location='<?php echo $baseurl.'account.html'?>'" class="cancelBtn btn btn-default btn-small"><span>Hủy bỏ</span></button>
                       </div>
                       
                    </div>
                 </div>
                  
                 
              </div>
              
           </form>
        </div>
     </div>
  </div>
</div> 
<script>

$(function()
{
        $("#list-agency").hide();
        var id = $('#level').val();
        if(id == 3)
        {
			//alert(id);
            $.ajax({
               type: 'get',
               beforeSend: function()
               {
                    $("#list-agency").show(); $("#list-place").hide();
               },
               url: '<?php echo site_url()?>get-agency-ajax',
               data: ({id: <?php echo $data->agency;?>}),
               success: function(data)
               {
                    $("#content-list-agency").html(data);
               }
            });
        }else{
			if(id == 4)
			{
				$.ajax({
				   type: 'get',
				   beforeSend: function()
				   {
						$("#list-place").show(); $("#list-agency").hide();
				   },
				   url: '<?php echo site_url()?>get-place-ajax',
				   data: ({id: <?php echo $data->place;?>}),
				   success: function(data)
				   {
						$("#content-list-place").html(data);
				   }
				});
			}else{
				 $("#list-agency").hide(); $("#list-place").hide();
				$input = '<input name="agency" value="xx" type="hidden"/>';
				$("#content-list-agency").html($input);
				$input_ = '<input name="place" value="xx" type="hidden"/>';
				$("#content-list-place").html($input_);
			}
        }
        
        $("#level").on('change', function()
        {
            var id = $(this).val();
            if(id == 3)
            {
                $.ajax({
                   type: 'get',
                   beforeSend: function()
                   {
                        $("#list-agency").show(); $("#list-place").hide();
                   },
                   url: '<?php echo site_url()?>get-agency-ajax',
                   success: function(data)
                   {
                        $("#content-list-agency").html(data);
                   }
                });
            }else{
				if(id == 4)
            {
                $.ajax({
                   type: 'get',
                   beforeSend: function()
                   {
                        $("#list-place").show(); $("#list-agency").hide();
                   },
                   url: '<?php echo site_url()?>get-place-ajax',
                   success: function(data)
                   {
                        $("#content-list-place").html(data);
                   }
                });
            }else{
				$("#list-agency").hide(); $("#list-place").hide();
                $input = '<input name="agency" value="xx" type="hidden"/>';
                $("#content-list-agency").html($input);
				$input_ = '<input name="place" value="xx" type="hidden"/>';
                $("#content-list-place").html($input_);
			}
                
            }
        })   
});

function convertimage(id, id_parse, img_show, check_image)
{
    var id = id;
    var id_parse = id_parse;
    var img_show = img_show;
    var check_image = check_image;
    var filesSelected = document.getElementById(id).files;
    if (filesSelected.length > 0)
    {
        var fileToLoad = filesSelected[0];

        var fileReader = new FileReader();

        fileReader.onload = function(fileLoadedEvent) 
        {
            $("#"+id_parse).attr('value', fileLoadedEvent.target.result);
            $("#"+check_image).val('1');
            //document.getElementById('cddd').html(fileLoadedEvent.target.result);
            $("#"+img_show).attr('src', fileLoadedEvent.target.result);
        };

        fileReader.readAsDataURL(fileToLoad);
    }
}
/*function convertimage()
{
    
        var filesSelected = document.getElementById("frm-img").files;
        if (filesSelected.length > 0)
        {
            var fileToLoad = filesSelected[0];
    
            var fileReader = new FileReader();
    
            fileReader.onload = function(fileLoadedEvent) 
            {
                var textAreaFileContents = document.getElementById
                (
                    "textAreaFileContents"
                    );
                $("#img_hd").attr('value', fileLoadedEvent.target.result);
            };
    
            fileReader.readAsDataURL(fileToLoad);
        }
    
    
    
}*/
</script>
<style>
body.flash-permanent .contentPanel {
    padding: 100px 0px 18px !important;
}
.cfr {
    line-height: 1px !important;padding: 15px 79px 0px 12px !important;height: 37px !important;
}
</style>